import { getappvm } from "./appvm";

import { getabsolutecatalogue } from "./getbaseurl";
import { states } from "./states";
import { urlclearhashandsearch } from "./urlclearhashandsearch";

export default async function csrinitialize() {
    const { pageerrors } = states;
    const appvm = getappvm();
    const summaryfile: string = getabsolutecatalogue();
    var path = summaryfile;
    path = urlclearhashandsearch(path);
    // menulist.unshift(path);
    try {
        // show_loading();
        if (!process.env.PRERENDER) {
            const { commoninitialize } = await import("./commoninitialize");
            await commoninitialize(states);
        }
        Reflect.set(appvm, "showerror", false);
        return;
    } catch (e_4) {
        console.error(e_4);
        // stop_loading();

        Reflect.set(appvm, "errorcontent", "加载失败 " + path);

        Reflect.set(appvm, "showerror", true);

        pageerrors.set(path, String(e_4));
        throw e_4;
    }
}
